<!DOCTYPE html>
<html lang="zh">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.staticfile.net/vue/2.7.8/vue.js"></script>
    <link href="../css/style.css" rel="stylesheet">
</head>

<body>
<div id="app">
    <h1>身世之谜</h1>
    <show-member-info name="龙海成" :age="age" :detail="{address: 'earth', language:'汉语'}"></show-member-info>
</div>
<script>
    Vue.component('show-member-info', {
        props: {
            name: {
                type: String,
                required: true
            },
            age: {
                type: Number,
                validator: function (val) {
                    return val > 0 && val <= 130
                }
            },
            detail: {
                type: Object,
                default: function () {
                    return {
                        address: 'US',
                        language: 'English'
                    }
                }
            }
        },
        template: `
          <div>
          姓名：{{ this.name }}<br>
          年龄：{{ this.age }}<br>
          地址：{{ this.detail.address }}<br>
          语言：{{ this.detail.language }}<br>
          </div>`
    })
    const vm = new Vue({
        el: '#app',
        data: {
            age: Math.round(Math.random() * 10)
        }
    });
</script>
</body>
</html>